package com.springmvc.entity;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;

public class Majiang {

	private static final List<String> list = new ArrayList<String>();

	static { // 1t 2b 3w df nf xf bf hz fc bb
//		setlist(list, 1, 9, "t", "b", "w");
//		set4(list, "0d", "0n", "0x", "0b", "1z", "2f", "3l");
		setlist(list, 1, 9, "条", "饼", "万");
		set4(list, "0东", "0西", "0南", "0北", "1中", "2發", "3口");
	}

	private static void setlist(List<String> list, int start, int end, String... names) {
		for (String name : names) {
			for (int i = start; i <= end; i++) {
				set4(list, i + name);
			}
		}
	}

	private static void set4(List<String> list, String... names) {
		for (String name : names) {
			for (int i = 0; i < 4; i++) {
				list.add(name);
			}
		}
	}

	/**
	 * 获取一副麻将 @Title: getMJDeque @return @return Deque<String> 返回类型 @throws
	 */
	public static Deque<String> getMJDeque() {
		Collections.shuffle(list);
		System.out.println(list);
		Collections.shuffle(list);
		Deque<String> deque = new LinkedList<String>(list);
		return deque;

	}

	public static void main(String[] args) {
		Deque<String> deque = getMJDeque();
		System.out.println(deque);
		System.out.println(deque.pop());
		System.out.println(deque.removeFirst());// 1
		System.out.println(deque.removeLast());// 2
		System.out.println(deque.getFirst());
		System.out.println(deque.getLast());
		System.out.print(deque);
		

		// MapCacheManager m = MapCacheManager.getInstance();
		// m.set(MjEnum.roomname, "1", "niaho");
		// m.set(MjEnum.roomname, "1", "niaho");
		// m.set(MjEnum.roomname, "1", "niaho");
		// m.set(MjEnum.roomname, "1", "niaho");
		// m.set(MjEnum.roomname, "2", "niaho");
		// m.get(MjEnum.roomname, "1");
		// m.get(MjEnum.roomname, "2");
		// m.select();
		// m.del(MjEnum.roomname, "2");
		// m.select();
	}

}
